package com.romaremez.testuser.src.userdata;

import java.io.Serializable;

/**
 * Presents a user
 */
public class User implements Serializable {
    private final String login;
    private String password;

    public User(String login, String password) {
        this.login = login;
        this.password = password;
    }

    public String getLogin() {
        return login;
    }

    public boolean isCorrectPassword(String pass) {
        return this.password.equals(pass);
    }

    public boolean isAdmin() {
        return "admin".equals(this.login);
    }

    @Override
    public boolean equals(Object obj) {
        if (getClass() != obj.getClass()) {
            return false;
        }
        User someUser = (User)obj;
         return (this.login.equals(someUser.login));
    }

    @Override
    public String toString() {
        return login;
    }
}
